package controller;

import pojo.Category;
import service.CategoryService;
import service.impl.CategoryServiceimpl;
import utils.JsonUtils;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author LiangHaiBo
 * @version 1.0
 * @date 2021.9.7 上午 9:48
 *
 * 完成分类的异步加载,获取分类信息数据
 */
@WebServlet("/category")
public class CategoryServlet extends BaseServlet {

    public String getcategoryall( HttpServletRequest request,HttpServletResponse response) throws IOException {
        //调用分类信息的业务接口
        CategoryService categoryService = new CategoryServiceimpl();
        List<Category> clist = categoryService.getCategoryall();

        String json = JsonUtils.list2json(clist);

        response.getWriter().write(json);

        return null;
    }


}
